home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / lcppb.zip / LCPPANS.ZIP / HEAD2.CPP < prev    next >
C/C++ Source or Header  |  1991-07-08  |  579b  |  31 lines

  1. // head2.cpp -- Use while instead of do/while
  2.  
  3. #include <iostream.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6.  
  7. #define MAXLINE 10
  8. #define NEWLINE '\n'
  9.  
  10. main()
  11. {
  12.   char c;
  13.   int linenum = 1;
  14.  
  15.   while (((c = getchar()) != EOF) && (linenum <= MAXLINE)) {
  16.     if (c == NEWLINE) {
  17.       linenum++;
  18.       cout << NEWLINE;
  19.     } else
  20.       putchar(c);
  21.   }
  22. }
  23.  
  24.  
  25. // Copyright (c) 1990 by Tom Swan. All rights reserved
  26. // Revision 1.00    Date: 10/24/1990   Time: 08:27 am
  27.  
  28. // Revision 1.01    Date: 07/08/1991   Time: 05:41 pm
  29. // Converted for Borland C++ 2.0
  30.  
  31.